/*
 * DetailControl.fx
 *
 * Created on 05-may-2009, 16:28:07
 */

package webooksfx.controller;

import java.lang.Exception;
import webooksfx.controller.Control;
import webooksfx.controller.SearchControl;
import webooksfx.model.Libro;
import webooksfx.view.DetailView;
import webooksfx.view.SearchView;

/**
 * @author Administrador
 */

public class DetailControl extends Control {
    //MODELO
    public var libro: Libro = bind this.req.libro on replace {
        if (libro != null) {
            (this.view as DetailView).setLibro(libro);
            this.showView();
        }
    };
	//EXCEPTION MODELO
	public var exception: Exception = bind this.req.exception on replace {
		if (exception != null) {
			searchControl.showException(exception);
        }
	}

    // CONTROLADORA
    var searchControl: SearchControl = null;
    override public function initControl (c1: Control) : Void {
        if (c1 instanceof SearchControl)
        searchControl = c1 as SearchControl;
    }

    public function detail (service: String, id_libro: String, formato_fecha: String) : Void {
        this.resetRequest();
        this.req.detail(service, id_libro, formato_fecha);
    }

    override public function showView () : Void {
        searchControl.hideView();
		super.showView();
    }

	public function showViewSearch () : Void {
		this.hideView();
		this.searchControl.showView();
	}
}
